#!/bin/env bash

function change_uos_apt_mirror {
    IS_CHANGED=$(cat /etc/apt/sources.list | grep '# OneKeyMan change mirror')
    if [ "$IS_CHANGED" != "" ]; then
        echo '已经替换过源'
        return
    fi

    echo '设置为debain 10源'
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    MIRROR="# OneKeyMan change mirror\ndeb http://mirrors.ustc.edu.cn/debian stable main contrib non-free\ndeb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free\n\n"
    sudo echo -e $MIRROR > /etc/apt/sources.list
    echo -e "\n更新系统apt源"
    sudo apt-get update
}

change_uos_apt_mirror
